<?php

	/** Abstraction des tests d'un joueur du club.
	 * @author Thomas Bayer
	 */	 
	 
class PlayerTests {
	
	/** Définition des attributs */
	
	private $_id;			// identifiant unique de la fiche de tests
	private $_memberId;		// identifiant unique du joueur
	private $_season;   	// identifiant de la saison associée a cette fiche
	private $_date;			// date de la prise des tests
	
	private $_height;		// taille du joueur
	private $_weight;		// poids du joueur
	private $_fatMass;		// masse grasse du joueur
	private $_jongleD;		// jongles pied droit
	private $_jongleG;		// jongles pied gauche
	private $_jongleT;		// jongles tête
	private $_jump;			// détente du joueur
	private $_speed10m;		// vitesse sur 10m
	private $_speed20m;		// vitesse sur 20m
	private $_speed40m;		// vitesse sur 40m
	
	private $_orientD;		// contrôle orienté + jeu court pied droit
	private $_orientG;		// contrôle orienté + jeu court pied gauche
	private $_amortiD;		// amorti + jeu long pied droit
	private $_amortiG;		// amorti + jeu long pied gauche
	private $_faceD;		// contrôle face + tir au but pied droit
	private $_faceG;		// contrôle face + tir au but pied gauche
	private $_slalomD;		// conduite + slalom pied droit
	private $_slalomG;		// conduite + slalom pied gauche
	private $_head;			// jeu de tête
	
	/** Constructeur */
	
	public function __construct($id = -1) {
		$this->_id = $id; 
	}
	
	/** Accès en lecture aux données */
	
	public function getId()			{ return $this->_id; }
	public function getMemberId()	{ return $this->_memberId; }
	public function getSeason()		{ return $this->_season; }
	public function getDate()		{ return $this->_date; }

	public function getHeight()		{ return $this->_height; }
	public function getWeight()		{ return $this->_weight; }
	public function getFatMass()	{ return $this->_fatMass; }
	public function getJongleD()	{ return $this->_jongleD; }
	public function getJongleG()	{ return $this->_jongleG; }
	public function getJongleT()	{ return $this->_jongleT; }
	public function getJump()		{ return $this->_jump; }
	public function getSpeed10m()	{ return $this->_speed10m; }
	public function getSpeed20m()	{ return $this->_speed20m; }
	public function getSpeed40m()	{ return $this->_speed40m; }
	
	public function getOrientD()	{ return $this->_orientD; }
	public function getOrientG()	{ return $this->_orientG; }
	public function getAmortiD()	{ return $this->_amortiD; }
	public function getAmortiG()	{ return $this->_amortiG; }
	public function getFaceD()		{ return $this->_faceD; }
	public function getFaceG()		{ return $this->_faceG; }
	public function getSlalomD()	{ return $this->_slalomD; }
	public function getSlalomG()	{ return $this->_slalomG; }
	public function getHead()		{ return $this->_head; }
	
	/** Accès en écriture aux données */
	
	public function setId($i)			{ $this->_id = $i; }
	public function setMemberId($p)		{ $this->_memberId = $p; }
	public function setSeason($s)		{ $this->_season = $s; }
	public function setDate($d)			{ $this->_date = $d; }
	
	public function setHeight($h)		{ $this->_height = $h; }
	public function setWeight($w)		{ $this->_weight = $w; }
	public function setFatMass($f)		{ $this->_fatMass = $f; }
	public function setJongleD($jD)		{ $this->_jongleD = $jD; }
	public function setJongleG($jG)		{ $this->_jongleG = $jG; }
	public function setJongleT($jT)		{ $this->_jongleT = $jT; }
	public function setJump($j)			{ $this->_jump = $j; }
	public function setSpeed10m($s1)	{ $this->_speed10m = $s1; }
	public function setSpeed20m($s2)	{ $this->_speed20m = $s2; }
	public function setSpeed40m($s4)	{ $this->_speed40m = $s4; }
	
	public function setOrientD($oD)		{ $this->_orientD = $oD; }
	public function setOrientG($oG)		{ $this->_orientG = $oG; }
	public function setAmortiD($aD)		{ $this->_amortiD = $aD; }
	public function setAmortiG($aG)		{ $this->_amortiG = $aG; }
	public function setFaceD($fD)		{ $this->_faceD = $fD; }
	public function setFaceG($fG)		{ $this->_faceG = $fG; }
	public function setSlalomD($sD)		{ $this->_slalomD = $sD; }
	public function setSlalomG($sG)		{ $this->_slalomG = $sG; }
	public function setHead($h)			{ $this->_head = $h; }
	
	/** Implémentation de l'interface de données persistantes **/
	
	public static function createTable() {
		$myDb = Database::getSingleton();
		
		// Table de stockage des fiches
		$query  = "CREATE TABLE IF NOT EXISTS `playerTests` ( \n";
		$query .= "  `id` 			INTEGER  	NOT NULL PRIMARY KEY auto_increment, \n";
		$query .= "  `memberId`   	INTEGER 	NOT NULL, \n";
		$query .= "  `season`   	SMALLINT  	NOT NULL, \n";
		$query .= "  `date`    		VARCHAR(10) NOT NULL, \n";
		$query .= "  `height`   	FLOAT		NOT NULL, \n";
		$query .= "  `weight`       FLOAT   	NOT NULL, \n";
		$query .= "  `fatMass`      FLOAT 		NOT NULL, \n";
		$query .= "  `jongleD`      INTEGER		NOT NULL, \n";
		$query .= "  `jongleG`      INTEGER		NOT NULL, \n";
		$query .= "  `jongleT`      INTEGER		NOT NULL, \n";
		$query .= "  `jump`			FLOAT 		NOT NULL, \n";
		$query .= "  `speed10m`		FLOAT 		NOT NULL, \n";
		$query .= "  `speed20m`		FLOAT 		NOT NULL, \n";
		$query .= "  `speed40m`		FLOAT 		NOT NULL, \n";
		$query .= "  `orientD`		FLOAT 		NOT NULL, \n";
		$query .= "  `orientG`		FLOAT 		NOT NULL, \n";
		$query .= "  `amortiD`		FLOAT 		NOT NULL, \n";
		$query .= "  `amortiG`		FLOAT 		NOT NULL, \n";
		$query .= "  `faceD`		FLOAT 		NOT NULL, \n";
		$query .= "  `faceG`		FLOAT 		NOT NULL, \n";
		$query .= "  `slalomD`		FLOAT 		NOT NULL, \n";
		$query .= "  `slalomG`		FLOAT 		NOT NULL, \n";
		$query .= "  `head`   		FLOAT      	NOT NULL);";
		$myDb->execute($query);
	}
	
	public static function dropTable() {
		$myDb = Database::getSingleton();
		$myDb->execute("DROP TABLE IF EXISTS `playerTests`; ");
	}
	
	public function create() {
		if ($this->_id != -1)
			throw new RuntimeException("PlayerTests/create()",
								   "The object is still present in database");
		
		// Instanciation dans la table persistante : Echappement des entrées
		$memberId	= Database::escape($this->_memberId);
		$season  	= Database::escape($this->_season);
		$date     	= Database::escape($this->_date->sqlFormat());
		$height    	= Database::escape($this->_height);
		$weight     = Database::escape($this->_weight);     
		$fatMass    = Database::escape($this->_fatMass);    
		$jongleD    = Database::escape($this->_jongleD);    
		$jongleG    = Database::escape($this->_jongleG);    
		$jongleT    = Database::escape($this->_jongleT);    
		$jump   	= Database::escape($this->_jump); 
		$speed10m  	= Database::escape($this->_speed10m); 
		$speed20m  	= Database::escape($this->_speed20m); 
		$speed40m  	= Database::escape($this->_speed40m); 
		$orientD  	= Database::escape($this->_orientD); 
		$orientG  	= Database::escape($this->_orientG); 
		$amortiD  	= Database::escape($this->_amortiD); 
		$amortiG  	= Database::escape($this->_amortiG); 
		$faceD  	= Database::escape($this->_faceD); 
		$faceG  	= Database::escape($this->_faceG); 
		$slalomD  	= Database::escape($this->_slalomD); 
		$slalomG  	= Database::escape($this->_slalomG); 
		$head	  	= Database::escape($this->_head); 
		
		// MIGRATION
		//$id = $this->_id;
	   
		// construction de la requête
		$query = <<<EOS
INSERT INTO `playerTests` VALUES 
('', '$memberId', '$season', '$date', '$height', '$weight',
 '$fatMass', '$jongleD', '$jongleG', '$jongleT', '$jump',
 '$speed10m', '$speed20m', '$speed40m', '$orientD', '$orientG',
 '$amortiD', '$amortiG', '$faceD', '$faceG', '$slalomD',
 '$slalomG', '$head'); 
EOS;

		// Injection de la requête dans le moteur de base :
		$myDb = Database::getSingleton();
		$ans = $myDb->executeInsert($query);
	   
		// Mise a jour de la clé identifiante
		$this->_id = $ans[0];
	}	

	public function update() {
		/* if ($this->_id = "")
			throw new RuntimeException("PlayerTests/update()",
								   "Aucun test sélectionné"); */
		
		// Instanciation dans la table persistante : Echappement des entrées
		$id			= Database::escape($this->_id);
		$memberId	= Database::escape($this->_memberId);
		$date     	= Database::escape($this->_date->sqlFormat());
		$height    	= Database::escape($this->_height);
		$weight     = Database::escape($this->_weight);     
		$fatMass    = Database::escape($this->_fatMass);  
		$jongleD    = Database::escape($this->_jongleD);    
		$jongleG    = Database::escape($this->_jongleG);    
		$jongleT    = Database::escape($this->_jongleT);    		
		$jump   	= Database::escape($this->_jump); 
		$speed10m  	= Database::escape($this->_speed10m); 
		$speed20m  	= Database::escape($this->_speed20m); 
		$speed40m  	= Database::escape($this->_speed40m); 
		$orientD  	= Database::escape($this->_orientD); 
		$orientG  	= Database::escape($this->_orientG); 
		$amortiD  	= Database::escape($this->_amortiD); 
		$amortiG  	= Database::escape($this->_amortiG); 
		$faceD  	= Database::escape($this->_faceD); 
		$faceG  	= Database::escape($this->_faceG); 
		$slalomD  	= Database::escape($this->_slalomD); 
		$slalomG  	= Database::escape($this->_slalomG); 
		$head	  	= Database::escape($this->_head); 
			   
		// construction de la requête
		$query = <<<EOS
UPDATE `playerTests`
SET `memberId` = '$memberId', 
	`date` = '$date', 
	`height` = '$height', 
	`weight` = '$weight', 
	`fatMass` = '$fatMass', 
	`jongleD` = '$jongleD', 
	`jongleG` = '$jongleG', 
	`jongleT` = '$jongleT', 
	`jump` = '$jump', 
	`speed10m` = '$speed10m', 
	`speed20m` = '$speed20m', 
	`speed40m` = '$speed40m',
	`orientD` = '$orientD', 
	`orientG` = '$orientG', 
	`amortiD` = '$amortiD', 
	`amortiG` = '$amortiG', 
	`faceD` = '$faceD', 
	`faceG` = '$faceG', 
	`slalomD` = '$slalomD', 
	`slalomG` = '$slalomG', 
	`head` = '$head'
WHERE id = '$id';
EOS;
					// Injection de la requête dans le moteur de base :
		$myDb = Database::getSingleton();
		$ans = $myDb->executeInsert($query);
	}		
	
	public static function read($key) {
		$myDb = Database::getSingleton();
		$key = Database::escape($key);
		
		// Recuperation des tests :
		$query = "SELECT * FROM `playerTests` WHERE `memberId` = $key;";
		$ans = Database::assoc($myDb->execute($query));
		
		if (! $ans)
			throw new Exception("PlayerTests/read() : Unknown key $key !",1);
			
		// chargement des membres d'instances :
		$aPlayerTests = new PlayerTests($ans["id"]);
		$aPlayerTests->setMemberId($ans["memberId"]);
		$aPlayerTests->setSeason($ans["season"]);
		$aPlayerTests->setDate(Date::fromSql($ans["date"]));
		$aPlayerTests->setHeight($ans["height"]);
		$aPlayerTests->setWeight($ans["weight"]);
		$aPlayerTests->setFatMass($ans["fatMass"]);
		$aPlayerTests->setJongleD($ans["jongleD"]);
		$aPlayerTests->setJongleG($ans["jongleG"]);
		$aPlayerTests->setJongleT($ans["jongleT"]);
		$aPlayerTests->setJump($ans["jump"]);
		$aPlayerTests->setSpeed10m($ans["speed10m"]);
		$aPlayerTests->setSpeed20m($ans["speed20m"]);
		$aPlayerTests->setSpeed40m($ans["speed40m"]);
		$aPlayerTests->setOrientD($ans["orientD"]);
		$aPlayerTests->setOrientG($ans["orientG"]);
		$aPlayerTests->setAmortiD($ans["amortiD"]);
		$aPlayerTests->setAmortiG($ans["amortiG"]);
		$aPlayerTests->setFaceD($ans["faceD"]);
		$aPlayerTests->setFaceG($ans["faceG"]);
		$aPlayerTests->setSlalomD($ans["slalomD"]);
		$aPlayerTests->setSlalomG($ans["slalomG"]);
		$aPlayerTests->setHead($ans["head"]);
		
		return $aPlayerTests;
	}

	public function delete() {
		// Ne devrait jamais être appelée, mais bon ...
		if ($this->_id == -1)
		  throw new RuntimeException("PlayerTests/delete()","non persistant object");

		$id = $this->_id;
		
		$myDb = Database::getSingleton();
		$query = "DELETE FROM `playerTests` WHERE `id` = $id ;";
		$myDb->execute($query);
	}
	
	public function tag() {
	 	$tmp = array();
	 	$tmp[0] = "PlayerTests";
	 	$tmp[1] = $this->_id;
	 	return $tmp;
	}
	
	public function soundsLike($o) {
			return ($this->_memberId == $o->_memberId && $this->_date == $o->_date); 
	}
	
	public function displayShort() {
		$memb = Member::read($this->_memberId);
		$title = $memb->getFirstName() . " " . $memb->getLastName();
		return $title;
	}

	public function displayName($id) {
		$memb = Member::read($id);
		$title = $memb->getFirstName() . " " . $memb->getLastName();
		return $title;
	}
	
	public function displaySheet() {
		if (isset($_GET['order']) && $_GET['order']!=NULL) {
			$order = $_GET['order'];
		} else {
			$order = 'date';
		}
		$table1 = "";
		$table2 = "";
		$myDb = Database::getSingleton();
		if ($order == 'date' 
		|| $order == 'height' 
		|| $order == 'weight' 
		|| $order == 'fatMass' 
		|| $order == 'jongleD' 
		|| $order == 'jongleG' 
		|| $order == 'jongleT' 
		|| $order == 'jump' 
		|| $order == 'head') {
			$query = $myDb->execute("SELECT * FROM `playerTests` ORDER BY $order DESC");
		} else {
			$query = $myDb->execute("SELECT * FROM `playerTests` ORDER BY $order ASC");
		}
		while ($dat = mysql_fetch_array($query)) {
			if ($dat["memberId"] == $this->_memberId) {
				$d = $dat["date"];
				$date = Date::fromSql($dat["date"])->prettyPrint();
				$height 	= $dat["height"] . " cm";
				$weight 	= $dat["weight"] . " kg";
				$fatMass	= $dat["fatMass"] . " %";
				$jongleD	= $dat["jongleD"];
				$jongleG	= $dat["jongleG"];
				$jongleT	= $dat["jongleT"];
				$jump 		= $dat["jump"] . " cm";
				$speed10m 	= $dat["speed10m"] . " s";
				$speed20m 	= $dat["speed20m"] . " s";
				$speed40m 	= $dat["speed40m"] . " s";
				$orientD 	= $dat["orientD"] . " s";
				$orientG 	= $dat["orientG"] . " s";
				$amortiD	= $dat["amortiD"] . " s";
				$amortiG	= $dat["amortiG"] . " s";
				$faceD		= $dat["faceD"] . " s";
				$faceG		= $dat["faceG"] . " s";
				$slalomD	= $dat["slalomD"] . " s";
				$slalomG	= $dat["slalomG"] . " s";
				$head		= $dat["head"] . "/20";
				
				if ($height == "0 cm")
					$height = "-";
				if ($weight == "0 kg")
					$weight = "-";
				if ($fatMass == "0 %")
					$fatMass = "-";
				if ($jongleD == "0")
					$jongleD = "-";
				if ($jongleG == "0")
					$jongleG = "-";
				if ($jongleT == "0")
					$jongleT = "-";
				if ($jump == "0 cm")
					$jump = "-";
				if ($speed10m == "0 s")
					$speed10m = "-";
				if ($speed20m == "0 s")
					$speed20m = "-";
				if ($speed40m == "0 s")
					$speed40m = "-";
				if ($orientD == "0 s")
					$orientD = "-";
				if ($orientG == "0 s")
					$orientG = "-";
				if ($amortiD == "0 s")
					$amortiD = "-";
				if ($amortiG == "0 s")
					$amortiG = "-";
				if ($faceD == "0 s")
					$faceD = "-";
				if ($faceG == "0 s")
					$faceG = "-";
				if ($slalomD == "0 s")
					$slalomD = "-";
				if ($slalomG == "0 s")
					$slalomG = "-";
				if ($head == "0/20")
					$head = "-";
					
				$table1 .= <<<EOS
<tr>
		<th><form action="web_fPlayerTestsEdit.php" method="post" accept-charset="utf-8 ">
			<input type="hidden" name="memberId" value="$this->_memberId" />
			<input type="hidden" name="date" value="$d" />
			<input type="hidden" name="height" value="$height" />
			<input type="hidden" name="weight" value="$weight" />
			<input type="hidden" name="fatMass" value="$fatMass" />
			<input type="hidden" name="jump" value="$jump" />
			<input type="hidden" name="speed10m" value="$speed10m" />
			<input type="hidden" name="speed20m" value="$speed20m" />
			<input type="hidden" name="speed40m" value="$speed40m" />
			<input type="hidden" name="head" value="$head" />
			<input type="hidden" name="jongleD" value="$jongleD" />
			<input type="hidden" name="jongleG" value="$jongleG" />
			<input type="hidden" name="jongleT" value="$jongleT" />
			<input type="hidden" name="orientD" value="$orientD" />
			<input type="hidden" name="orientG" value="$orientG" />
			<input type="hidden" name="amortiD" value="$amortiD" />
			<input type="hidden" name="amortiG" value="$amortiG" />
			<input type="hidden" name="faceD" value="$faceD" />
			<input type="hidden" name="faceG" value="$faceG" />
			<input type="hidden" name="slalomD" value="$slalomD" />
			<input type="hidden" name="slalomG" value="$slalomG" />
			<input type="submit" value="Modifier" class="edit"/></form></th>
		<td> $date </td> 
		<td> $height </td> 
		<td> $weight </td> 
		<td> $fatMass </td> 
		<td> $jump </td> 
		<td> $speed10m </td> 
		<td> $speed20m </td> 
		<td> $speed40m </td> 
		<td> $head </td>
</tr>
EOS;

				$table2 .= <<<EOS
<tr>
		<th><form action="web_fPlayerTestsEdit.php" method="post" accept-charset="utf-8 ">
			<input type="hidden" name="memberId" value="$this->_memberId" />
			<input type="hidden" name="date" value="$d" />
			<input type="hidden" name="height" value="$height" />
			<input type="hidden" name="weight" value="$weight" />
			<input type="hidden" name="fatMass" value="$fatMass" />
			<input type="hidden" name="jump" value="$jump" />
			<input type="hidden" name="speed10m" value="$speed10m" />
			<input type="hidden" name="speed20m" value="$speed20m" />
			<input type="hidden" name="speed40m" value="$speed40m" />
			<input type="hidden" name="head" value="$head" />
			<input type="hidden" name="jongleD" value="$jongleD" />
			<input type="hidden" name="jongleG" value="$jongleG" />
			<input type="hidden" name="jongleT" value="$jongleT" />
			<input type="hidden" name="orientD" value="$orientD" />
			<input type="hidden" name="orientG" value="$orientG" />
			<input type="hidden" name="amortiD" value="$amortiD" />
			<input type="hidden" name="amortiG" value="$amortiG" />
			<input type="hidden" name="faceD" value="$faceD" />
			<input type="hidden" name="faceG" value="$faceG" />
			<input type="hidden" name="slalomD" value="$slalomD" />
			<input type="hidden" name="slalomG" value="$slalomG" />
			<input type="submit" value="Modifier" class="edit"/></form></th>
		<td> $date </td>
		<td> $jongleD </td> 
		<td> $jongleG </td> 
		<td> $jongleT </td>  
		<td> $orientD </td> 
		<td> $orientG </td> 
		<td> $amortiD </td> 
		<td> $amortiG </td> 
		<td> $faceD </td> 
		<td> $faceG </td> 
		<td> $slalomD </td> 
		<td> $slalomG </td>
</tr>
EOS;
			}
		}
		return array($table1, $table2);
	}
	
	public function displayOne() {
		$table = $this->displaySheet();
		$page = <<<EOS
<div align="left">
<table class="resultset">
<tr>
	<th rowspan = 2>Tests physiques</th> 
	<th rowspan = 2> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=date">Date des tests</a> </th> 
	<th rowspan = 2> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=height">Taille</a> </th> 
	<th rowspan = 2> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=weight">Poids</a> </th> 
	<th rowspan = 2> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=fatMass">Masse grasse</a> </th>
	<th rowspan = 2> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=jump">Détente</a> </th>
	<th colspan = "3"> Vitesse </th> 
	<th rowspan = 2> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=head">Jeu de tête</a> </th>
</tr>
<tr>
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=speed10m">10m</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=speed20m">20m</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=speed40m">40m</a> </th> 
</tr>
$table[0]
</table>
<br />
<br />
<br />
</div>

EOS;

		$page .= <<<EOS
<div align="left">
<table class="resultset">
<tr>
	<th rowspan = 2>Tests techniques</th> 
	<th rowspan = 2> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=date">Date des tests</a> </th>
	<th colspan = "3"> Jongles </th>
	<th colspan = "2"> Cont orienté + Jeu court </th>
	<th colspan = "2"> Amorti + Jeu long </th> 
	<th colspan = "2"> Cont face + Tir </th> 
	<th colspan = "2"> Slalom 20m </th>
</tr>
<tr>
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=jongleD">D</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=jongleG">G</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=jongleT">T</a> </th>
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=contD">D</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=contG">G</a> </th>
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=amortiD">D</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=amortiG">G</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=faceD">D</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=faceG">G</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=slalomD">D</a> </th> 
	<th> <a href="web_fPlayerTestsDisplay.php?id=$this->_memberId&order=slalomG">G</a> </th> 
</tr>
$table[1]
</table>
</div>

EOS;
		
	return $page;		
	}
	
	public function displayLine() {
		if (isset($_GET['order']) && $_GET['order']!=NULL) {
				$order = $_GET['order'];
			} else {
				$order = 1;
			}
		$table_name = array();
		$table_d = array();
		$table_date = array();
		$table_height = array();
		$table_weight = array();
		$table_fatMass = array();
		$table_jongleD = array();
		$table_jongleG = array();
		$table_jongleT = array();
		$table_jump = array();
		$table_speed10m = array();
		$table_speed20m = array();
		$table_speed40m = array();
		$table_orientD = array();
		$table_orientG = array();
		$table_amortiD = array();
		$table_amortiG = array();
		$table_faceD = array();
		$table_faceG = array();
		$table_slalomD = array();
		$table_slalomG = array();
		$table_head = array();
		$myDb = Database::getSingleton();
		$query = $myDb->execute("SELECT `id`, `memberId`, `season`, MAX(`date`) AS max_date, `height`,
								 `weight`, `fatMass`, `jongleD`, `jongleG`, `jongleT`,
								 `jump`, `speed10m`, `speed20m`, `speed40m`, `orientD`,
								 `orientG`, `amortiD`, `amortiG`, `faceD`, `faceG`,
								 `slalomD`, `slalomG`, `head` 
								 FROM `playerTests`
								 WHERE `memberId` = $this->_memberId							 
								 GROUP BY `memberId`");	
		
		while ($dat = mysql_fetch_array($query)) {
			if($dat["memberId"] ==  $this->_memberId) {
				$name = $this->displayName($dat["memberId"]);
				$d = $dat["max_date"];
				$date = Date::fromSql($dat["max_date"])->prettyPrint();
				$height = $dat["height"] . " cm";
				$weight = $dat["weight"] . " kg";
				$fatMass = $dat["fatMass"] . " %";
				$jongleD	= $dat["jongleD"];
				$jongleG	= $dat["jongleG"];
				$jongleT	= $dat["jongleT"];
				$jump = $dat["jump"] . " cm";
				$speed10m       = $dat["speed10m"] . " s";
				$speed20m       = $dat["speed20m"] . " s";
				$speed40m       = $dat["speed40m"] . " s";
				$orientD        = $dat["orientD"] . " s";
				$orientG        = $dat["orientG"] . " s";
				$amortiD        = $dat["amortiD"] . " s";
				$amortiG        = $dat["amortiG"] . " s";
				$faceD          = $dat["faceD"] . " s";
				$faceG          = $dat["faceG"] . " s";
				$slalomD        = $dat["slalomD"] . " s";
				$slalomG        = $dat["slalomG"] . " s";
				$head           = $dat["head"] . " /20";
				
				if ($height == "0 cm")
						$height = "-";
				if ($weight == "0 kg")
						$weight = "-";
				if ($fatMass == "0 %")
						$fatMass = "-";
				if ($jongleD == "0")
					$jongleD = "-";
				if ($jongleG == "0")
					$jongleG = "-";
				if ($jongleT == "0")
					$jongleT = "-";
				if ($jump == "0 cm")
						$jump = "-";
				if ($speed10m == "0 s")
						$speed10m = "-";
				if ($speed20m == "0 s")
						$speed20m = "-";
				if ($speed40m == "0 s")
						$speed40m = "-";
				if ($orientD == "0 s")
						$orientD = "-";
				if ($orientG == "0 s")
						$orientG = "-";
				if ($amortiD == "0 s")
						$amortiD = "-";
				if ($amortiG == "0 s")
						$amortiG = "-";
				if ($faceD == "0 s")
						$faceD = "-";
				if ($faceG == "0 s")
						$faceG = "-";
				if ($slalomD == "0 s")
						$slalomD = "-";
				if ($slalomG == "0 s")
						$slalomG = "-";
				if ($head == "0 /20")
						$head = "-";
					
			array_push($table_name, $name);
			array_push($table_d, $d);
			array_push($table_date, $date);
			array_push($table_height, $height);
			array_push($table_weight, $weight);
			array_push($table_fatMass, $fatMass);
			array_push($table_jongleD, $jongleD);
			array_push($table_jongleG, $jongleG);
			array_push($table_jongleT, $jongleT);
			array_push($table_jump, $jump);
			array_push($table_speed10m, $speed10m);
			array_push($table_speed20m, $speed20m);
			array_push($table_speed40m, $speed40m);
			array_push($table_orientD, $orientD);
			array_push($table_orientG, $orientG);
			array_push($table_amortiD, $amortiD);
			array_push($table_amortiG, $amortiG);
			array_push($table_faceD, $faceD);
			array_push($table_faceG, $faceG);
			array_push($table_slalomD, $slalomD);
			array_push($table_slalomG, $slalomG);
			array_push($table_head, $head);
			
				}
			}
		return array($order, $table_name, $table_d, $table_date, $table_height, 
					 $table_weight, $table_fatMass, $table_jongleD, $table_jongleG, $table_jongleT,
					 $table_jump, $table_speed10m, $table_speed20m, $table_speed40m, $table_orientD,
					 $table_orientG, $table_amortiD, $table_amortiG, $table_faceD, $table_faceG,
					 $table_slalomD, $table_slalomG, $table_head);
        }
        
}       	
?>